<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>用JS任意控制手机上的APP | RobotJs | 用JS任意控制手机上的APP</title>
  <link rel="stylesheet" href="assets/fonts.css">
  <link rel="stylesheet" href="assets/style.css">
  <link rel="stylesheet" href="assets/sh.css">
  <link rel="canonical" href="https://nodejs.org/api/hbuilder.html">
</head>
<body class="alt apidoc" id="api-section-hbuilder">
  <div id="content" class="clearfix">
    <div id="column2" class="interior">
      <div id="intro" class="interior">
        <a href="/" title="返回首页">
          RobotJs
        </a>
      </div>
      <ul>
<li><a class="nav-startnow" href="startnow.html">开始</a></li>
<li><a class="nav-hbuilder active" href="hbuilder.html">Demo, 调试运行</a></li>
<li><a class="nav-hello" href="hello.html">Hello World</a></li>
<li><a class="nav-autojs-vue" href="autojs-vue.html">与vue交互</a></li>
<li><a class="nav-normal" href="normal.html">常用api</a></li>
<li><a class="nav-links" href="links.html">支持库(超强)</a></li>
<li><a class="nav-patchs" href="patchs.html">热更新</a></li>
<li><a class="nav-deploy" href="deploy.html">打包</a></li>
<li><a class="nav-remote" href="remote.html">远程部署</a></li>
<li><a class="nav-java" href="java.html">与java交互</a></li>
<li><a class="nav-qa" href="qa.html">Q&amp;A - 常见问题</a></li>
<li><a class="nav-https-miren-lovemi-ren-colorui-document-" href="https://miren.lovemi.ren/colorui-document/" target="_blank" rel="noopener noreferrer">UI设计</a><div class="line"></div></li>
<li><a class="nav--" href="#">【API文档】:</a></li>
<li><a class="nav-overview" href="overview.html">Overview - 综述</a></li>
<li><a class="nav-documentation" href="documentation.html">Tip - 阅读说明</a></li>
<li><a class="nav-coordinatesBasedAutomation" href="coordinatesBasedAutomation.html">Click - 基于坐标的操作</a></li>
<li><a class="nav-widgetsBasedAutomation" href="widgetsBasedAutomation.html">开始 - 基于控件的操作</a></li>
<li><a class="nav-widgetsBasedAutomation-widgetsbasedautomation_simpleactionautomator" href="widgetsBasedAutomation.html#widgetsbasedautomation_simpleactionautomator">Click - 基于控件的操作</a></li>
<li><a class="nav-widgetsBasedAutomation-widgetsbasedautomation_uiselector" href="widgetsBasedAutomation.html#widgetsbasedautomation_uiselector">UiSelector - 查找控件</a></li>
<li><a class="nav-widgetsBasedAutomation-widgetsbasedautomation_uiobject" href="widgetsBasedAutomation.html#widgetsbasedautomation_uiobject">UiObject - 控件</a></li>
<li><a class="nav-app" href="app.html">App - 应用</a></li>
<li><a class="nav-canvas" href="canvas.html">Canvas - 画布</a></li>
<li><a class="nav-console" href="console.html">Console - 控制台</a></li>
<li><a class="nav-crypto" href="crypto.html">Crypto - 加解密与消息摘要</a></li>
<li><a class="nav-device" href="device.html">Device - 设备</a></li>
<li><a class="nav-dialogs" href="dialogs.html">Dialogs - 对话框</a></li>
<li><a class="nav-engines" href="engines.html">Engines - 脚本引擎</a></li>
<li><a class="nav-events" href="events.html">Events - 事件与监听</a></li>
<li><a class="nav-floaty" href="floaty.html">Floaty - 悬浮窗</a></li>
<li><a class="nav-files" href="files.html">Files - 文件系统</a></li>
<li><a class="nav-globals" href="globals.html">Globals - 一般全局函数</a></li>
<li><a class="nav-http" href="http.html">Http - HTTP</a></li>
<li><a class="nav-images" href="images.html">Images - 图片与图色处理</a></li>
<li><a class="nav-keys" href="keys.html">Keys - 按键模拟</a></li>
<li><a class="nav-media" href="media.html">Media - 多媒体</a></li>
<li><a class="nav-modules" href="modules.html">Modules - 模块</a></li>
<li><a class="nav-sensors" href="sensors.html">Sensors - 传感器</a></li>
<li><a class="nav-shell" href="shell.html">Shell - Shell命令</a></li>
<li><a class="nav-storages" href="storages.html">Storages - 本地存储</a></li>
<li><a class="nav-threads" href="threads.html">Threads - 多线程</a></li>
<li><a class="nav-timers" href="timers.html">Timers - 定时器</a></li>
<li><a class="nav-ui" href="ui.html">UI - 用户界面</a></li>
<li><a class="nav-https-developer-mozilla-org-zh-CN-docs-Mozilla-Projects-Rhino-Scripting_Java" href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Projects/Rhino/Scripting_Java">Work with Java - 调用Java API</a></li>
</ul>
<div class="line"></div>



    </div>

    <div id="column1" data-id="hbuilder" class="interior">
      <header>
        <h1>用JS任意控制手机上的APP</h1>
        <div id="gtoc">
          <p>
            <a href="index.html" name="toc">索引</a> |
            <a href="all.html">查看全部</a>
          </p>
        </div>
        <hr>
      </header>

      <div id="toc">
        <h2>目录</h2>
        <ul>
<li><span class="stability_undefined"><a href="#hbuilder_js_app">用JS任意控制手机上的APP</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder_10">(10分钟就可以上手)</a></span></li>
<li><span class="stability_undefined"><a href="#hbuilder_qq_862460452">QQ群： 862460452</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder_1_app_10">1. 对app的控制(10分钟就可以上手)</a></span></li>
</ul>
</li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#hbuilder_a">A. 开发环境</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder">代码与工具</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder_1_hbuilderx_https_www_dcloud_io_hbuilderx_html">1. 下载安装开发工具<a href="https://www.dcloud.io/hbuilderx.html">HbuilderX</a></a></span></li>
<li><span class="stability_undefined"><a href="#hbuilder_2">2. 克隆或下载源码</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder_a_1">a.示例项目(入门推荐)</a></span></li>
<li><span class="stability_undefined"><a href="#hbuilder_b_ui">b.空白项目(最小化项目，不含UI交互，高手使用)</a></span></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#hbuilder_b">B. 运行与调试</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder_1">运行示例项目</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder_1">1. 初始化项目环境配置</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder_1_1_hbuiderx_1"><code>[步骤1]</code>1. HbuiderX菜单 -&gt; 运行 -&gt; 运行到终端 -&gt; 1.初始化/依赖包</a></span></li>
<li><span class="stability_undefined"><a href="#hbuilder_2_2_hbuiderx_2"><code>[步骤2]</code>2. HbuiderX菜单 -&gt; 运行 -&gt; 运行到终端 -&gt; 2.更新/安装基座（可忽略）</a></span></li>
<li><span class="stability_undefined"><a href="#hbuilder_3_3_hbuiderx"><code>[步骤3]</code>3. HbuiderX菜单 -&gt; 运行 -&gt; 手机或模拟器 -&gt; 运行基座选择 -&gt; 自定义基座</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#hbuilder_2_1">2. 执行 (调试/运行)</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder_4_3_1"><code>[步骤4]</code> 3.1. 运行到手机</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder_1_usb_adb">1. USB线连接手机(需ADB生效)</a></span></li>
<li><span class="stability_undefined"><a href="#hbuilder_2_hbuiderx">2. HbuiderX菜单 -&gt; 运行 -&gt; 手机或模拟器 -&gt; 选择你的手机名字</a></span></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#hbuilder_c_app">C. 发布/升级，生成APP</a></span><ul>
<li><span class="stability_undefined"><a href="#hbuilder_deploy_html">请看<a href="deploy.html">打包</a>章节</a></span></li>
</ul>
</li>
</ul>

      </div>

      <div id="apicontent">
        <h1>用JS任意控制手机上的APP<span><a class="mark" href="#hbuilder_js_app" id="hbuilder_js_app">#</a></span></h1>
<h2>(10分钟就可以上手)<span><a class="mark" href="#hbuilder_10" id="hbuilder_10">#</a></span></h2>
<pre><code>(10分钟就可以上手)
</code></pre><p>帮助开发者,快速生产友好的控制脚本程序</p>
<h2>QQ群： 862460452<span><a class="mark" href="#hbuilder_qq_862460452" id="hbuilder_qq_862460452">#</a></span></h2>
<h3>1. 对app的控制(10分钟就可以上手)<span><a class="mark" href="#hbuilder_1_app_10" id="hbuilder_1_app_10">#</a></span></h3>
<pre><code class="lang-js">launchApp(&quot;微信&quot;); 
click(&quot;发现&quot;);
click(&quot;朋友圈&quot;);
sleep(3000);
click(desc(&quot;评论&quot;));
</code></pre>
<p><a href="http://robots.shen-x.com/static/git/1.jpg">效果图1</a>，
<a href="http://robots.shen-x.com/static/git/3.jpg">效果图2</a>，
<a href="http://robots.shen-x.com/static/git/6.jpg">效果图3</a>，
<a href="http://robots.shen-x.com/static/git/5.jpg">效果图4</a>，</p>
<p><img src='images/1.jpg' width="100%">
<img src='images/9.png' width="200">
<img src='images/3.jpg' width="200">
<img src='images/8.png' width="200"></p>
<h1>A. 开发环境<span><a class="mark" href="#hbuilder_a" id="hbuilder_a">#</a></span></h1>
<h2>代码与工具<span><a class="mark" href="#hbuilder" id="hbuilder">#</a></span></h2>
<h3>1. 下载安装开发工具<a href="https://www.dcloud.io/hbuilderx.html">HbuilderX</a><span><a class="mark" href="#hbuilder_1_hbuilderx_https_www_dcloud_io_hbuilderx_html" id="hbuilder_1_hbuilderx_https_www_dcloud_io_hbuilderx_html">#</a></span></h3>
<pre><code>新版本: https://www.dcloud.io/hbuilderx.html
老版本： https://pan.baidu.com/s/1W0IEokddywK5iqoIx7biKw?pwd=1234 
</code></pre><h3>2. 克隆或下载源码<span><a class="mark" href="#hbuilder_2" id="hbuilder_2">#</a></span></h3>
<h4>a.示例项目(入门推荐)<span><a class="mark" href="#hbuilder_a_1" id="hbuilder_a_1">#</a></span></h4>
<p>此方式为整个AJ_VUE演示项目，里面有Color UI组件库，演示，模板等，建议用户可以下载 此项目运行用于查看演示效果，通过里面的示例，可以快速掌握项目用法。</p>
<p>github地址(github)：<a href="https://github.com/yooge/robot">https://github.com/yooge/robot</a></p>
<p>gitee地址[网速快]：<a href="https://gitee.com/vnool/autojs-vue">https://gitee.com/vnool/autojs-vue</a></p>
<p>直接下载zip包：</p>
<h4>b.空白项目(最小化项目，不含UI交互，高手使用)<span><a class="mark" href="#hbuilder_b_ui" id="hbuilder_b_ui">#</a></span></h4>
<p>项目地址：请github搜索 autojs-vue-mini</p>
<p>此连接为一个空白的AJ_VUE示例工程，原生ui组件，熟练开发后使用</p>
<p>.</p>
<h1>B. 运行与调试<span><a class="mark" href="#hbuilder_b" id="hbuilder_b">#</a></span></h1>
<h2>运行示例项目<span><a class="mark" href="#hbuilder_1" id="hbuilder_1">#</a></span></h2>
<h3>1. 初始化项目环境配置<span><a class="mark" href="#hbuilder_1" id="hbuilder_1">#</a></span></h3>
<h4><code>[步骤1]</code>1. HbuiderX菜单 -&gt; 运行 -&gt; 运行到终端 -&gt; 1.初始化/依赖包<span><a class="mark" href="#hbuilder_1_1_hbuiderx_1" id="hbuilder_1_1_hbuiderx_1">#</a></span></h4>
<h4><code>[步骤2]</code>2. HbuiderX菜单 -&gt; 运行 -&gt; 运行到终端 -&gt; 2.更新/安装基座（可忽略）<span><a class="mark" href="#hbuilder_2_2_hbuiderx_2" id="hbuilder_2_2_hbuiderx_2">#</a></span></h4>
<h4><code>[步骤3]</code>3. HbuiderX菜单 -&gt; 运行 -&gt; 手机或模拟器 -&gt; 运行基座选择 -&gt; 自定义基座<span><a class="mark" href="#hbuilder_3_3_hbuiderx" id="hbuilder_3_3_hbuiderx">#</a></span></h4>
<p>步骤1. 初始化是为了安装<code>robot-tools</code>组件</p>
<p>步骤2. 安装基座，文件下载后会存放到目录unpackage/debug/android_debug.apk</p>
<p>步骤3. 启用调试基座(手机上的app)</p>
<ul>
<li>基座是用于动态调试的APP程序。</li>
<li>如果步骤2步骤3忘记操作，会意外安装错误的手机程序，会提示Robot对象不存在</li>
</ul>
<p><img src='images/start-app.png' width="400">
.</p>
<h3>2. 执行 (调试/运行)<span><a class="mark" href="#hbuilder_2_1" id="hbuilder_2_1">#</a></span></h3>
<h4><code>[步骤4]</code> 3.1. 运行到手机<span><a class="mark" href="#hbuilder_4_3_1" id="hbuilder_4_3_1">#</a></span></h4>
<h5>1. USB线连接手机(需ADB生效)<span><a class="mark" href="#hbuilder_1_usb_adb" id="hbuilder_1_usb_adb">#</a></span></h5>
<h5>2. HbuiderX菜单 -&gt; 运行 -&gt; 手机或模拟器 -&gt; 选择你的手机名字<span><a class="mark" href="#hbuilder_2_hbuiderx" id="hbuilder_2_hbuiderx">#</a></span></h5>
<div class="signature"><ul>
<li><p>脚本代码，电脑上编辑，手机上可以立即运行 *</p>
</li>
<li><p>VUE代码，电脑上编辑，手机上可以立即同步。查看效果，需要重启页面 *</p>
</li>
<li><p>运行到模拟器，wifi连接 (另外聊)</p>
</li>
</ul>
</div><p>.</p>
<h1>C. 发布/升级，生成APP<span><a class="mark" href="#hbuilder_c_app" id="hbuilder_c_app">#</a></span></h1>
<h2>请看<a href="deploy.html">打包</a>章节<span><a class="mark" href="#hbuilder_deploy_html" id="hbuilder_deploy_html">#</a></span></h2>

      </div>
    </div>
  </div>
  <script src="assets/sh_main.js"></script>
  <script src="assets/sh_javascript.min.js"></script>
  <script>highlight(undefined, undefined, 'pre');</script>
  <!-- __TRACKING__ -->
</body>
</html>